package tinybase.basic;

import tinybase.pf.Statistic;

public enum RC {
	
	/*
	 * Statistic Return Code
	 */
	STAT_INVALID_ARGS(Statistic.STAT_BASE + 1), 
	STAT_KNOWN_KEY(Statistic.STAT_BASE + 2), 
	
	/**
	 * PF Return Code
	 */
	SUCCESS(0), //return OK 
	PF_PAGEPINNED(RedBase.START_PF_WARN + 0), // page pinned in buffer
	PF_PAGENOTINBUF(RedBase.START_PF_WARN + 1), // page to be unpinned is not in
												// buffer
	PF_INVALIDPAGE(RedBase.START_PF_WARN + 2), // invalid page number
	PF_FILEOPEN(RedBase.START_PF_WARN + 3), // file handle already open
	PF_CLOSEDFILE(RedBase.START_PF_WARN + 4), // file is closed
	PF_PAGEFREE(RedBase.START_PF_WARN + 5), // page already free
	PF_PAGEUNPINNED(RedBase.START_PF_WARN + 6), // page already unpinned
	PF_EOF(RedBase.START_PF_WARN + 7), // end of file
	PF_TOOSMALL(RedBase.START_PF_WARN + 8), PF_LASTWARN(PF_TOOSMALL),

	PF_NOMEM(RedBase.START_PF_ERR - 0), // out of memory
	PF_NOBUF(RedBase.START_PF_ERR - 1), // out of buffer space
	PF_INCOMPLETEREAD(RedBase.START_PF_ERR - 2), // incomplete read of page from
													// file
	PF_INCOMPLETEWRITE(RedBase.START_PF_ERR - 3), // incomplete write of page to
													// file
	PF_HDRREAD(RedBase.START_PF_ERR - 4), // incomplete read of header from file
	PF_HDRWRITE(RedBase.START_PF_ERR - 5), // incomplete write of header to file
	
	// Internal PF errors:

	PF_PAGEINBUF(RedBase.START_PF_ERR - 6), // new allocated page already in
											// buffer
	PF_HASHNOTFOUND(RedBase.START_PF_ERR - 7), // hash table entry not found
	PF_HASHPAGEEXIST(RedBase.START_PF_ERR - 8), // page already exists in hash
												// table
	PF_INVALIDNAME(RedBase.START_PF_ERR - 9), // invalid file name

	PF_UNIX(RedBase.START_PF_ERR - 10), // Unix error
	PF_LASTERR(PF_UNIX),
	
//    PF_CANNOTCREATEFILE, 
//    PF_FILENOTFOUND, 
//    PF_FAILEDTODELETEFILE,

    /**
     * RM Return Code	
     */
    RM_INVIABLERID(RedBase.START_RM_WARN + 0),
    RM_UNREADRECORD(RedBase.START_RM_WARN + 1), // unread record
    RM_INVALIDRECSIZE(RedBase.START_RM_WARN + 2), // invalid record size
    RM_INVALIDSLOTNUM(RedBase.START_RM_WARN + 3), // invalid slot number
    RM_RECORDNOTFOUND(RedBase.START_RM_WARN + 4), // record not found
    RM_INVALIDCOMPOP(RedBase.START_RM_WARN + 5), // invalid comparison operator
    RM_INVALIDATTR(RedBase.START_RM_WARN + 6), // invalid attribute parameters
    RM_NULLPOINTER(RedBase.START_RM_WARN + 7), // pointer is null
    RM_SCANOPEN(RedBase.START_RM_WARN + 8), // scan is open
    RM_CLOSEDSCAN(RedBase.START_RM_WARN + 9), // scan is closed
    RM_CLOSEDFILE(RedBase.START_RM_WARN + 10),// file handle is closed
	RM_LASTWARN(RedBase.START_RM_WARN + 10),
	
	RM_EOF(PF_EOF),	// work-around for rm_test
	
	RM_NOMEM(RedBase.START_RM_ERR - 0),
	RM_LASTERROR(RM_NOMEM),
	
	
	/*
	 * IX Return Code
	 */
	IX_INVALIDINDEXNO  (RedBase.START_IX_WARN + 0), // invalid index number
	IX_INVALIDCOMPOP   (RedBase.START_IX_WARN + 1), // invalid comparison operator
	IX_INVALIDATTR     (RedBase.START_IX_WARN + 2), // invalid attribute parameters
	IX_NULLPOINTER     (RedBase.START_IX_WARN + 3), // pointer is null
	IX_SCANOPEN        (RedBase.START_IX_WARN + 4), // scan is open
	IX_CLOSEDSCAN      (RedBase.START_IX_WARN + 5), // scan is closed
	IX_CLOSEDFILE      (RedBase.START_IX_WARN + 6), // file handle is closed
	IX_ENTRYNOTFOUND   (RedBase.START_IX_WARN + 7), // entry not found
	IX_ENTRYEXISTS     (RedBase.START_IX_WARN + 8), // entry already exists
	IX_EOF             (RedBase.START_IX_WARN + 9), // end of file
	IX_LASTWARN        (IX_EOF),

	IX_NOMEM           (RedBase.START_IX_ERR - 0),  // no memory
	IX_LASTERROR       (IX_NOMEM),

	_9999(-9999),
	
	/*
	 * SM Return Code
	 */
	SM_INVALIDDBNAME   (RedBase.START_SM_WARN + 0), // invalid DB name
	SM_CHDIRFAILED     (RedBase.START_SM_WARN + 1), // cannot change directory
	SM_INVALIDRELNAME  (RedBase.START_SM_WARN + 2), // invalid relation name
	SM_DUPLICATEDATTR  (RedBase.START_SM_WARN + 3), // duplicated attribute names
	SM_RELEXISTS       (RedBase.START_SM_WARN + 4), // relation already exists
	SM_RELNOTFOUND     (RedBase.START_SM_WARN + 5), // relation not found
	SM_ATTRNOTFOUND    (RedBase.START_SM_WARN + 6), // relation/attribute not found
	SM_INDEXEXISTS     (RedBase.START_SM_WARN + 7), // index already exists
	SM_INDEXNOTFOUND   (RedBase.START_SM_WARN + 8), // index not found
	SM_FILEIOFAILED    (RedBase.START_SM_WARN + 9), // data file I/O failed
	SM_INVALIDFORMAT   (RedBase.START_SM_WARN + 10), // invalid data file format
	SM_PARAMUNDEFINED  (RedBase.START_SM_WARN + 11), // parameter undefined
	SM_LASTWARN        (SM_PARAMUNDEFINED),

	SM_NOMEM           (RedBase.START_SM_ERR - 0),  // no memory
	SM_LASTERROR       (SM_NOMEM);

	
	
	
	private Integer value;

	private RC(int value) {
		this.value = value;
	}

	private RC() {

	}

	private RC(RC rc) {
		this.value = rc.value;
	}

	public Integer getValue() {
		return this.value;
	}
}
